package com.yjx.util;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private T Data;
    private String msg;
    public long timestamp;

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<T>();
        result.setData(data);
        result.setCode(200);
        result.setMsg("操作成功");
        result.setTimestamp(System.currentTimeMillis());
        return result;
    }

    public static <T> Result<T> fail(String msg, Integer code){
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMsg(msg);
        result.setTimestamp(System.currentTimeMillis());
        result.setData(null);
        return result;
    }
}
